package com.fzkjjt.shardingjdbc.mapper;

import com.fzkjjt.shardingjdbc.entity.FzUser;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @program: sharding-jdbc
 * @description:
 * @author: FangZhen
 * @create: 2021-04-27 10:59
 **/
@Mapper
public interface UserMapper {

    @Insert("insert into fz_user(nickname,password,age,sex,birthday) values(#{nickname},#{password},#{age},#{sex},#{birthday})")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id") //回显主键
    void addUSer(FzUser user);

    @Select("select * from fz_user")
    List<FzUser> findUsers();
}
